package com.hzeport.bgs22emduty.inbound.api;

import com.hzeport.bgs22emduty.config.WebSocketServer;
import com.hzeport.bgs22emduty.dto.WebSocketSendInfoDTO;
import com.masa.common.core.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@RequestMapping("/webSocketSendInfo")
@Api(value = "webSocketSendInfo", tags = "消息发送")
@Slf4j
public class WebSocketController {

    private final WebSocketServer webSocketServer;

    @ApiOperation(value = "发送全部", notes = "发送全部")
    @PostMapping("/sendAll")
    public BaseResult<String> sendAll(@RequestBody WebSocketSendInfoDTO webSocketSendInfoDTO) {
        WebSocketServer.sendAll(webSocketSendInfoDTO.getMessage());
        return BaseResult.ok();
    }

    @ApiOperation(value = "发送全部杭州海关", notes = "发送全部杭州海关")
    @PostMapping("/sendAllHZ")
    public BaseResult<String> sendAllHZ(@RequestBody WebSocketSendInfoDTO webSocketSendInfoDTO) {
        webSocketServer.sendAllHZ(webSocketSendInfoDTO.getMessage(),webSocketSendInfoDTO.getScreenMessage());
        return BaseResult.ok();
    }

    @ApiOperation(value = "发送全部总署", notes = "发送全部总署")
    @PostMapping("/sendAllZS")
    public BaseResult<String> sendAllZS(@RequestBody WebSocketSendInfoDTO webSocketSendInfoDTO) {
        webSocketServer.sendAllZS(webSocketSendInfoDTO.getMessage(),webSocketSendInfoDTO.getScreenMessage(),webSocketSendInfoDTO.getModule());
        return BaseResult.ok();
    }

    @ApiOperation(value = "发送全部Distribute", notes = "发送全部Distribute")
    @PostMapping("/sendAllDistribute")
    public BaseResult<String> sendAllDistribute(@RequestBody WebSocketSendInfoDTO webSocketSendInfoDTO) {
        log.info( "发送全部Distribute入参{}" ,  webSocketSendInfoDTO);
        webSocketServer.sendAllDistribute(webSocketSendInfoDTO.getMessage(),webSocketSendInfoDTO.getScreenMessageDistribute(),webSocketSendInfoDTO.getModule());
        return BaseResult.ok();
    }


}
